package com.lzb.findphone.adapter;

import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.findphone.R;
import com.lzb.findphone.basic.ProviderMultiAdapter;
import com.lzb.findphone.bean.SoundBean;

public class HomeSoundAdapter extends ProviderMultiAdapter<SoundBean> {

    public HomeSoundAdapter() {
        addItemProvider(new HomeSoundProvider());
    }

    private class HomeSoundProvider extends BaseItemProvider<SoundBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_home_sound;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SoundBean bean) {
            baseViewHolder.setImageResource(R.id.ivHomeSoundItemImg, bean.getImg());
            baseViewHolder.setText(R.id.tvHomeSoundItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivHomeSoundItemBorder).setVisibility(View.VISIBLE);
                baseViewHolder.getView(R.id.ivHomeSoundItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivHomeSoundItemBorder).setVisibility(View.GONE);
                baseViewHolder.getView(R.id.ivHomeSoundItemSel).setVisibility(View.GONE);
            }
        }
    }

}
